<html xmlns="http://www.w3.org/1999/xhtml"  
     xmlns:h="http://java.sun.com/jsf/html"      
     xmlns:f="http://java.sun.com/jsf/core"
     xmlns:ui="http://java.sun.com/jsf/facelets"
     xmlns:r="http://ricchieri.com/facelets"
     xmlns:p="http://primefaces.org/ui">  
 <h:head>
 </h:head>  
 <h:body>
 	<ui:composition>  

 	  
	     	<p:fieldset legend="#{msg.fieldset_common_data}" style="margin-top:10px">  
		     	<h:panelGrid columns="3" id="panelCommonData">
		     		<h:outputLabel for="firstName" value="#{msg.first_name}" />
		     		<p:inputText id="firstName" value="#{user.firstName}" required="true" requiredMessage="#{msg.requiredName}" title="#{component.valid ? '' : manageBean.getErrorMessage(component.clientId)}" validatorMessage="#{msg.lengthFirstName}">
		     			<f:validateLength minimum="2" /> 
		     			<p:ajax event="blur" update="nameMsg" />
		     		</p:inputText>
		     		<p:message id="nameMsg" for="firstName" display="icon"/>
		     		
		     		<h:outputLabel for="lastName" value="#{msg.last_name}" />  
				    <p:inputText id="lastName" value="#{user.lastName}" required="true" requiredMessage="#{msg.requiredLastName}" title="#{component.valid ? '' : manageBean.getErrorMessage(component.clientId)}" validatorMessage="#{msg.lengthLastName}">
				        <f:validateLength minimum="2" /> 
		     			<p:ajax event="blur" update="lastNameMsg" />
		     		</p:inputText>
		     		<p:message id="lastNameMsg" for="lastName" display="icon"/> 
				    
		     		<h:outputLabel for="documentType" value="#{msg.documentType}"/>
		     		<p:selectOneMenu id="documentType" required="false" requiredMessage="#{msg.requiredDniType}" value="#{manageBean.documentType}" title="#{component.valid ? '' : manageBean.getErrorMessage(component.clientId)}">
		                <f:selectItems value="#{manageBean.documents}" />   
		            </p:selectOneMenu> 
		            <p:message id="documentTypeMsg" for="documentType" display="icon"/>
		            
		     		<h:outputLabel for="dni" value="#{msg.documentNum}" />
				    <p:inputText id="dni" value="#{user.dni}" required="true" requiredMessage="#{msg.requiredDni}" title="#{component.valid ? '' : manageBean.getErrorMessage(component.clientId)}" validatorMessage="#{msg.lengthDNI}" maxlength="8" onkeypress="if(event.which &lt; 48 || event.which &gt; 57) return false;">
				    	<f:validateLength minimum="7" /> 
				    </p:inputText>
				    <p:message id="dniMsg" for="dni" display="icon"/> 
		
		     		<h:outputLabel for="password" value="#{msg.password}" rendered="#{showPassword}"/>
				    <p:password id="password" value="#{user.password}" rendered="#{showPassword}" required="true" requiredMessage="#{msg.requiredPassword}" match="confirmPassword" title="#{component.valid ? '' : manageBean.getErrorMessage(component.clientId)}" validatorMessage="#{msg.lengthPassword}">
				    <f:validateLength minimum="6" /> 
				    </p:password>
				    <p:message id="passwordMsg" for="password" display="icon" rendered="#{showPassword}"/> 
				    
				    <h:outputLabel for="confirmPassword" value="#{msg.passwordConfirmation}" rendered="#{showPassword}"/>
				    <p:password id="confirmPassword" value="#{user.confirmPassword}" rendered="#{showPassword}" required="true" requiredMessage="#{msg.requiredPassword}" title="#{component.valid ? '' : manageBean.getErrorMessage(component.clientId)}">
				    </p:password>
				    <p:message id="confirmPasswordMsg" for="confirmPassword" display="icon" rendered="#{showPassword}"/> 
		
				</h:panelGrid>
			</p:fieldset>
			
			<p:outputPanel rendered="#{showRoles}"> 
				<p:fieldset legend="#{msg.fieldset_roles}" style="margin-top:10px" toggleable="true" toggleSpeed="500" id="fieldSetRol" >  
			     	<h:panelGrid columns="3">
			     		<p:selectManyCheckbox value="#{manageBean.selectedRoles}">  
							<f:selectItems value="#{manageBean.roleTypes}" />
							<f:ajax render="panelCommonJobData" />
				        </p:selectManyCheckbox>
					</h:panelGrid>
				</p:fieldset>
			</p:outputPanel> 
			<p:outputPanel id="panelCommonJobData" rendered="#{showJobData}"> 
				<p:fieldset legend="#{msg.fieldsetCommonJobData}" style="margin-top:10px" id="fieldSetCommonJob" rendered="#{manageBean.isRequiredCuil()}">  
					<h:panelGrid columns="3"> 		
			            <p:outputLabel for="cuil" value="#{msg.cuil}" />
					    <p:inputMask id="cuil" value="#{user.cuil}" 
					    	title="#{component.valid ? '' : manageBean.getErrorMessage(component.clientId)}" 
					    	maxlength="10" 
					    	onkeypress="if(event.which &lt; 48 || event.which &gt; 57) return false;" 
					    	mask="99-99999999-9"
					    	required="true" requiredMessage="#{msg.requiredCuil}"/>
					    <p:message id="cuilMsg" for="cuil" display="icon" /> 
					</h:panelGrid>
				</p:fieldset>
			</p:outputPanel> 
			
			<p:fieldset legend="#{msg.fieldset_email}" toggleable="true" toggleSpeed="500" id="fieldSetEmail" style="margin-top:10px">
		     	<h:panelGrid columns="3">
					<h:outputLabel for="emailType" value="#{msg.emailType}"/>
		     		<p:selectOneMenu id="emailType" value="#{manageBean.emailType}">
		                <f:selectItems value="#{manageBean.emailsTypes}" />   
		            </p:selectOneMenu> 
		            <p:message id="emailTypeMsg" for="emailType" display="icon"/>
		            			
		     		<h:outputLabel for="email" value="#{msg.email}" />
		     		<p:inputText id="email" value="#{manageBean.email}" title="#{component.valid ? '' : manageBean.getErrorMessage(component.clientId)}">
		     			<f:validator validatorId="com.ricchieri.validator.EmailValidator" />
		     		</p:inputText>
		     		<p:message id="emailMsg" for="email" display="icon"/> 
		     		
				</h:panelGrid>	

				<div style="text-align:right">
					<p:commandButton value="#{msg.saveEmail}" update="fieldSetEmail" partialSubmit="true" process="fieldSetEmail" action="#{manageBean.addEmail}"/>
				</div>
							
				<p:dataTable var="mail" value="#{manageBean.emailDataModel}" id="emailTable"
									style="padding-top:15px"
									selection="#{manageBean.selectedUserEmail}"
									rowKey="#{mail.emailType.description}" emptyMessage="#{msg.noRecordsFound}">  
	  
	  				<p:column selectionMode="single" style="width:10%" headerText="#{msg.main}"/>
			        <p:column headerText="#{msg.email}" style="width:30%">  
		            	<h:outputText value="#{mail.email}" />   
	        		</p:column> 
	        		
	        		<p:column headerText="#{msg.emailType}" style="width:30%">  
		            	<h:outputText value="#{manageBean.obtainDescription(mail.emailType.description)}" />   
	        		</p:column>
	        		
	        		<p:column headerText="#{msg.actions}" style="width:30%">
	        			<center>
		        			<p:commandLink styleClass="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only button-action" style="font-size:14px" actionListener="#{manageBean.deleteUserEmail(mail)}" update="emailTable" process="@this" >
								<span class="ui-button-text ui-c"><i class="icon-remove-sign"></i><r:space/><r:space/>#{msg.delete}</span>
							</p:commandLink>
						</center>
	        		</p:column>
	        		
			    </p:dataTable>
			</p:fieldset>     	
			
			<p:fieldset legend="#{msg.fieldset_phones}" toggleable="true" toggleSpeed="500" id ="fieldSetPhone" style="margin-top:10px">
		     	<h:panelGrid columns="3">
		     		<h:outputLabel for="phoneType" value="#{msg.phoneType}"/>
		     		<p:selectOneMenu id="phoneType" value="#{manageBean.phone}">
		                <f:selectItems value="#{manageBean.phonesTypes}" />   
		            </p:selectOneMenu> 
		            <p:message id="phoneTypeMsg" for="phoneType" display="icon"/>
		            
		           	<h:outputLabel for="number" value="#{msg.phone_number}" />
		     		<p:inputText id="number" value="#{manageBean.number}" title="#{component.valid ? '' : manageBean.getErrorMessage(component.clientId)}" onkeypress="if(event.which &lt; 48 || event.which &gt; 57) return false;">
		     			<p:ajax event="blur" update="numberMsg" />
		     		</p:inputText>
		     		<p:message id="numberMsg" for="number" display="icon"/> 
		     	</h:panelGrid>
		     	  			
				<div style="text-align:right">
					<p:commandButton value="#{msg.savePhone}" update="fieldSetPhone" partialSubmit="true" process="fieldSetPhone" action="#{manageBean.addPhone}"/>
				</div>
							
				<p:dataTable var="pho" value="#{manageBean.phoneDataModel}"
									style="padding-top:15px" id="phoneTable"
									selection="#{manageBean.selectedUserPhone}"
									rowKey="#{pho.phoneType.description}" emptyMessage="#{msg.noRecordsFound}">
	 
	 				<p:column selectionMode="single" style="width:10%" headerText="#{msg.main}"/>
			        <p:column headerText="#{msg.phone_number}" style="width:30%">  
		            	<h:outputText value="#{pho.number}" />   
	        		</p:column> 
	        		
	        		<p:column headerText="#{msg.phoneType}" style="width:30%">  
		            	<h:outputText value="#{manageBean.obtainDescription(pho.phoneType.description)}" />   
	        		</p:column>
	        		
	        		<p:column headerText="#{msg.actions}" style="width:30%">  
	        			<center>
		        			<p:commandLink styleClass="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only button-action" style="font-size:14px" actionListener="#{manageBean.deleteUserPhone(pho)}" update="phoneTable" process="@this" >
								<span class="ui-button-text ui-c"><i class="icon-remove-sign"></i><r:space/><r:space/>#{msg.delete}</span>
							</p:commandLink>
						</center>
	        		</p:column>
	        		
			    </p:dataTable>
		     	
		     	
		     </p:fieldset>
     </ui:composition>    
</h:body>
</html> 